package com.chinasoftinc.facommon.utils;

import java.util.Timer;

/**
 * 任务执行器
 *
 * @since 2022-05-07
 */
public class Execute {
    private Timer timer;
    private ExecuteTask task;

    public Execute() {
        this.timer = new Timer();
    }

    public void schedule(ExecuteTask task, long delay) {
        this.task = task;
        timer.schedule(task, delay);
    }

    public void cancel() {
        task.cancel();
        timer.cancel();
    }
}
